<template>
  <div :class="styles.my">
    <Header :data="user" />
    <History />
    <Setting />
    <!-- <van-button type="primary" color="#999" block>退出登录</van-button> -->
  </div>
</template>

<script lang="ts">
import { ref } from 'vue';
import { useUser } from '@/stores';
import { useShareAppMessage } from '@tarojs/taro';
import { Header, History, Setting } from './components';
import { defaultShareImage } from '@/const/images';
import styles from './index.module.less';
import { useLoginInterCeptor } from '@/hooks/login';

export default {
  components: {
    Header,
    History,
    Setting,
  },
  setup() {
    const userStore = useUser();
    const user = ref(userStore.userinfo);

    useLoginInterCeptor(async () => {
      user.value = await userStore.getUserInfo();
    });

    useShareAppMessage(() => {
      return {
        title: '阿姨直聘',
        path: `/pages/index/index?shareid=${user.value.id}`,
        imageUrl: defaultShareImage,
      };
    });

    return {
      styles,
      user,
    };
  },
};
</script>
